﻿<UserControl x:Class="HighLandirect.Presentation.Views.CustomerListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:p="clr-namespace:HighLandirect.Presentation.Properties"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:HighLandirect.Applications.ViewModels;assembly=HighLandirect.Applications"
             mc:Ignorable="d" d:DataContext="{d:DesignInstance vm:CustomerListViewModel}">
    <UserControl.Resources>
        <SolidColorBrush x:Key="LightBlueBrushKey">#FFC6D2F5</SolidColorBrush>
    </UserControl.Resources>
    <DockPanel>
        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar>
                <Button Command="{Binding AddNewCommand}" Content="{x:Static p:Resources.Add}" Background="{StaticResource LightBlueBrushKey}"></Button>
                <Separator Width="10" />
                <TextBox Width="150" Text="{Binding SearchString, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=true, 
                     ValidatesOnDataErrors=true, NotifyOnValidationError=true}" />
                <Button Command="{Binding SearchCommand}" Content="検索" />
                <Separator Width="10"/>
                <Button Command="{Binding AddSendCustomerCommand}" Content="送主として追加"/>
                <Button Command="{Binding AddResceiveCustomerCommand}" Content="送先として追加"/>
                <Separator Width="10" />
                <Button Command="{Binding PrintAtenaSealCommand}" Content="宛名シール印刷"/>
                <Button Command="{Binding PrintKokyakuDaichoCommand}" Content="顧客台帳印刷"/>
                <Separator Width="10" />
                <CheckBox Checked="ShowDeletedData" Unchecked="HideDeletedData" Content="削除行を表示" />
                <Button Command="{Binding RemoveCommand}" Content="{x:Static p:Resources.Remove}" Visibility="Hidden"/>
            </ToolBar>
        </ToolBarTray>
        <DataGrid ItemsSource="{Binding Customers}" SelectedItem="{Binding SelectedCustomer}" AutoGenerateColumns="False" CanUserAddRows="False"
                  SelectionChanged="ListViewSelectionChanged" FontSize="14">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding CustNo}" Header="{x:Static p:Resources.CustNo}" Width="70"/>
                <DataGridTextColumn Binding="{Binding CustName}" Header="{x:Static p:Resources.CustName}" Width="100"/>
                <DataGridTextColumn Binding="{Binding PostalCD}" Header="{x:Static p:Resources.PostalCD}" Width="60"/>
                <DataGridTextColumn Binding="{Binding CityName}" Header="{x:Static p:Resources.CityName}" Width="70"/>
                <DataGridTextColumn Binding="{Binding Address1}" Header="{x:Static p:Resources.Address1}" Width="150"/>
                <DataGridTextColumn Binding="{Binding Address2}" Header="{x:Static p:Resources.Address2}" Width="150"/>
                <DataGridTextColumn Binding="{Binding Phone}" Header="{x:Static p:Resources.Phone}" Width="100"/>
                <DataGridTextColumn Binding="{Binding MailAddress}" Header="{x:Static p:Resources.MailAddress}" Width="100"/>
                <DataGridTemplateColumn Header="{x:Static p:Resources.Label}" Width="30" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding Label}"
                                 Checked="LabelCheckBox_Checked" Unchecked="LabelCheckBox_Checked"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Binding="{Binding LatestSend}" Header="最終荷主日" Width="100" />
                <DataGridTextColumn Binding="{Binding LatestResceive}" Header="最終宛先日" Width="100" />
                <DataGridTemplateColumn Header="一覧に出さない" Width="30" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding Delete}"
                                 Checked="DeleteCheckBox_Checked" Unchecked="DeleteCheckBox_Checked"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</UserControl>
